﻿/****************************************
 *  copyright (c) 2008 leo shen
 *  
 *  all rights reserved         
 * 
 *  e-mail : syl.lucky@gmail.com
 * *************************************/

using System;
using System.Collections.Generic;
using System.Text;

namespace DotUpdater.Core.Versions
{
    public class LastModifiedVersion : IVersion
    {
        DateTime m_lastModifedTime;

        public LastModifiedVersion(DateTime lastModifedTime)
        {
            m_lastModifedTime = lastModifedTime;
        }

        public DateTime LastModifiedTime
        {
            get { return m_lastModifedTime; }
            set { m_lastModifedTime = value; }
        }

        #region IVersion Members

        public bool IsLasterThan(IVersion version)
        {
            if (version == null)
                throw new ArgumentNullException("version");
            LastModifiedVersion theVersion = version as LastModifiedVersion;
            if (theVersion == null)
                throw new ArithmeticException("the version is not LastModifiedVersion");

            DateTime dt1 = new DateTime(this.LastModifiedTime.Year, this.LastModifiedTime.Month, this.LastModifiedTime.Day, this.LastModifiedTime.Hour, this.LastModifiedTime.Minute, this.LastModifiedTime.Second);
            DateTime dt2 = new DateTime(theVersion.LastModifiedTime.Year, theVersion.LastModifiedTime.Month, theVersion.LastModifiedTime.Day, theVersion.LastModifiedTime.Hour, theVersion.LastModifiedTime.Minute, theVersion.LastModifiedTime.Second);
            return dt1.CompareTo(dt2) == 1;
        }

        #endregion
    }
}
